import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes=[
  {
    name:'home',
    path:'/',
    component:()=>import('../views/home')
  },
  {
    name:'tips',
    path:'/tips',
    component:()=>import('../views/tips')
  },
  {
    name:'single',
    path:'/single',
    component:()=>import('../views/single')
  },
  {
    name:'singleResult',
    path:'/singleResult',
    component:()=>import('../views/singleResult')
  },
  {
    name:'loves',
    path:'/loves',
    component:()=>import('../views/loves')
  },
  {
    name:'lovesResult',
    path:'/lovesResult',
    component:()=>import('../views/lovesResult')
  },
  {
    name:'couple',
    path:'/couple',
    component:()=>import('../views/couple')
  },
  {
    name:'coupleResult',
    path:'/coupleResult',
    component:()=>import('../views/coupleResult')
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to,from,next)=>{
  if(window.localStorage.getItem('agreeRules')==='1'||to.name==='tips'){
    next()
  }else {
    next({
      name:'tips'
    })
  }
})


export default router
